window.onload = async function() {
    const params = new URLSearchParams(window.location.search);
    const id = params.get('id');
    if (!id) {
        document.getElementById('productDetail').innerText = '未指定商品ID';
        return;
    }
    const p = await apiGetProduct(id);
    if (!p) {
        document.getElementById('productDetail').innerText = '商品不存在';
        return;
    }
    document.getElementById('productDetail').innerHTML = `
    <h2>${p.title}</h2>
    <img src="${p.coverImage || '/default.jpg'}" alt="图片" style="width:200px;">
    <div>价格：￥${p.price}</div>
    <div>描述：${p.description}</div>
    <div>卖家：${p.sellerName || ''}</div>
  `;
};
